package com.zunipe.trainticketsystem.database.handler;

import com.zunipe.trainticketsystem.TrainTicketApplication;
import com.zunipe.trainticketsystem.database.dao.OrderDao;
import com.zunipe.trainticketsystem.database.entity.Order;

import java.util.List;

public class OrderHandler {

    private final OrderDao orderDao;

    public OrderHandler() {
        orderDao = TrainTicketApplication.getInstance().getOrderDao();
    }

    public List<Order> getOrderList() {
        return orderDao.findAll();
    }

    public void paymentOrder(int id, String status) {
        orderDao.updateStatus(id, status);
    }

    public Order getOrderById(int id) {
        return orderDao.findById(id);
    }

    public int createOrder(Order order) {
        return orderDao.insert(order);
    }
}
